using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using THSERP.BusinessEntities;
using THSERP.BaseProvider;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraGrid;
using THSLib;
namespace THSERP.Modules.Report
{
    public partial class guiReportCenter : THSERPScreen
    {
        public guiReportCenter()
        {
            InitializeComponent();

            ADReportsController objReportsController = new ADReportsController();
            DataSet ds = objReportsController.GetReportsByType(ReportModule.cstReportTypeSale);
            if (ds.Tables.Count > 0)
                fld_dgcReports.DataSource = ds.Tables[0];
        }

        private void navBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            ADReportsController objReportsController = new ADReportsController();
            DataSet ds = objReportsController.GetReportsByType(e.Link.Item.Tag.ToString());
            if (ds.Tables.Count > 0)
                fld_dgcReports.DataSource = ds.Tables[0];
        }

        private void button1_Click(object sender, EventArgs e)
        {
            guiReportCenter gui = new guiReportCenter();
            gui.MdiParent = THSApp.MainScreen;
            gui.WindowState = FormWindowState.Maximized;
            gui.Show();
        }

        private void fld_dgvReports_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
            if (e.Button == MouseButtons.Left && e.Column.FieldName == "ADReportName")
            {
                DataRow row = fld_dgvReports.GetDataRow(e.RowHandle);
                ReportForm form = (ReportForm)BaseClassFactory.GetClass(String.Format("THSERP.Modules.Report.{0}", row["ADReportNo"].ToString()));
                if (form != null)
                {
                    form.MdiParent = THSApp.MainScreen;
                    form.Module = this.Module;
                    form.Show();
                }
            }
                
        }
    }
}